import request from '../utils/api'

// 获取任务列表
export const getTaskList = (params) => {
  return request({
    url: '/optimization-task/list',
    method: 'get',
    params
  })
}

// 获取任务详情
export const getTaskDetail = (id) => {

  return request({
    url: `/optimization-task/${id}`,
    method: 'get'
  })
}

// 添加任务
export const addTask = (data) => {
  return request({
    url: '/optimization-task',
    method: 'post',
    data
  })
}

// 更新任务
export const updateTask = (data) => {
  return request({
    url: `/optimization-task/${data.id}`,
    method: 'put',
    data
  })
}

// 删除任务
export const deleteTask = (id) => {
  return request({
    url: `/optimization-task/${id}`,
    method: 'delete'
  })
}

// 批量删除任务
export const batchDeleteTasks = (ids) => {
  return request({
    url: '/optimization-task/batch',
    method: 'delete',
    params: { ids: ids.join(',') }
  })
}

// 执行任务
export const executeTask = (id) => {
  return request({
    url: `/optimization-task/${id}/execute`,
    method: 'post'
  })
}

// 批量执行任务
export const batchExecuteTasks = (ids) => {
  return request({
    url: '/optimization-task/batch-execute',
    method: 'post',
    data: ids
  })
}

// 获取任务统计信息
export const getTaskStats = () => {
  return request({
    url: '/optimization-task/stats',
    method: 'get'
  })
}